/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package utils;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 *
 * @author banhbaochay
 */
public class ImageFilter extends FileFilter{
    private final String[] acceptExt = {"jpg", "png", "ico", "bmp", "gif", "jpeg"};

        @Override
        public boolean accept(File f) {
            boolean accept = false;
            if (f.isDirectory()) {
                return true;
            }

            String fileName = f.getName();
            for (String ext : acceptExt) {
                if (fileName.toLowerCase().endsWith(ext)) {
                    accept = true;
                    break;
                }
            }
            return accept;
        }

        @Override
        public String getDescription() {
            return "Image Files";
        }
}
